package ljl.alg.jianzhioffer.round3.easy;

import commons.TreeNode;

public class _54_kthLargest {

    public int kthLargest(TreeNode root, int k) {
        i = k;
        dfs(root);
        return v;
    }

    int i;
    int v;
    void dfs(TreeNode node) {
        if (node == null)
            return;
        dfs(node.right);
        if (i-- == 1) {
            v = node.val;
            return;
        }
        dfs(node.left);
    }

}
